package com.study.manage.mvc.v2;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.study.manage.dal.BlogRepository;
import com.study.manage.dal.BlogStatDayRepository;
import com.study.manage.dal.EvaluateApplyRepository;
import com.study.manage.dal.EvaluateRepository;
import com.study.manage.dal.OrdersRepository;
import com.study.manage.dto.AjaxResponse;
import com.study.manage.dto.SessionUser;
import com.study.manage.mvc.common.UploadController;
import com.study.manage.service.EvaluateService;

@Controller
@RequestMapping("/v2/index")
public class V2IndexController extends UploadController {

    @Autowired
    private EvaluateApplyRepository evaluateApplyRepository;
    @Autowired
    private EvaluateRepository evaluateRepository;
    @Autowired
    private BlogRepository blogRepository;
    @Autowired
    private OrdersRepository ordersRepository;
    @Autowired
    private BlogStatDayRepository blogStatDayRepository;
    @Autowired
    private EvaluateService evaluateService;

    @RequestMapping(path = "index", method = RequestMethod.GET)
    public String index(HttpServletRequest request, ModelMap model, HttpServletResponse response) {
        return "v2/index/index";
    }


    @ResponseBody
    @RequestMapping(path = "index-count", method = RequestMethod.GET)
    public AjaxResponse indexCount() {
        AjaxResponse ajax = new AjaxResponse(true);
        SessionUser su = this.getUserInfo();
        return ajax.setObj(evaluateService.statCount(su.getId(), null, null));
    }
}
